<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:p="http://primefaces.org/ui"
	xmlns:ui="http://java.sun.com/jsf/facelets">

<h:body>

	<ui:composition template="masterpage.xhtml">

		<ui:define name="cont">


			<h:form  id="formReceita" class="form-horizontal" action="#"
				style="border-radius: 0px;" acceptcharset="ISO-8859-1">

				<div class="form-group">
					<h:outputLabel  id="outDescricao" 
									value="Descrição"
									styleClass="col-sm-3 control-label" />
					
					<div class="col-sm-6">
						<h:inputText 	id="inptDescricao" 
										styleClass="form-control"
										value="#{novaReceitaBean.receita.descricao}" required="true" >
										</h:inputText>
						
						<h:message for="inptDescricao" class="mensagens" />
					</div>
				</div>

				<div class="form-group">
					<h:outputLabel id="outValor" 
									value="Valor R$"
									styleClass="col-sm-3 control-label" />
					<div class="col-sm-6">
						<h:inputText id="inptValor" 
									styleClass="form-control money"
									value="#{novaReceitaBean.receita.valor}">
							<f:convertNumber pattern="#,###,##0.00" />
						</h:inputText>
					</div>
				</div>

				<div class="form-group">
					<h:outputLabel id="outDataVencimento" value="Data Recebimento"
						styleClass="col-sm-3 control-label" />
					<div class="col-sm-6">
					
					<div class="elements">
						<p:calendar value="#{novaReceitaBean.receitaData.data}" 
									tipy="text"
									id="dataRecebimento" 
									required="true" 
									pattern="dd/MM/yyyy"  
									style="float:left;"/>
							
							<div class="checkbox">
								<label> <h:selectBooleanCheckbox 
									style="margin-left:25px;"
									id="chkEfetuada"
									value="#{novaReceitaBean.efetuada}" /> Efetuada
								</label>
							</div>
							
							<div class="checkbox">
								<label> <h:selectBooleanCheckbox 
									id="chkRepetir" 
									style="margin-left:25px;" 
									value="#{novaReceitaBean.repetir}">
									<f:ajax event="click" render="pnlRepetir"/>
									</h:selectBooleanCheckbox> Repetir
							</label>
							</div>
							
									<h:panelGroup id="pnlRepetir">
										<h:selectOneMenu rendered="#{novaReceitaBean.repetir == true ? true : false}" 
														style="width:70px; 
														float:left;
														margin-left:10px;" 
														styleClass="form-control"
														value="#{novaReceitaBean.prestacao}">
											
											<f:selectItem itemLabel="1x" itemValue="1" />
											<f:selectItem itemLabel="2x" itemValue="2" />
											<f:selectItem itemLabel="3x" itemValue="3"/>
											<f:selectItem itemLabel="4x" itemValue="4"/>
											<f:selectItem itemLabel="5x" itemValue="5"/>
											<f:selectItem itemLabel="6x" itemValue="6"/>
											<f:selectItem itemLabel="7x" itemValue="7"/>
											<f:selectItem itemLabel="8x" itemValue="8"/>
											<f:selectItem itemLabel="9x" itemValue="9"/>
											<f:selectItem itemLabel="10x" itemValue="10"/>
											<f:selectItem itemLabel="11x" itemValue="11"/>
											<f:selectItem itemLabel="12x" itemValue="12"/>
										</h:selectOneMenu>
									</h:panelGroup>
							<br/>
						</div>
						<br/>
						<h:message for="dataRecebimento" class="mensagens"/>
							
					</div>
				</div>

				<br />

				<div class="form-group">
					<h:outputLabel id="outTipo" value="Tipo"
						styleClass="col-sm-3 control-label" />
					<div class="col-sm-6">
						<h:selectOneMenu styleClass="form-control" value="#{novaReceitaBean.receita.tipo}" converter="entityConverter" >
							<f:selectItems itemValue="#{tipo}" value="#{novaReceitaBean.tipoList}" var="tipo" itemLabel="#{tipo.descricao}" />
						</h:selectOneMenu>
					</div>
				</div>

				<div class="form-group">
					<h:outputLabel id="outConta" value="Contas"
								styleClass="col-sm-3 control-label" />
					<div class="col-sm-6">
						<h:selectOneMenu  styleClass="form-control" value="#{novaReceitaBean.receita.conta}" converter="entityConverter">
							<f:selectItems itemValue="#{conta}" value="#{novaReceitaBean.contaList}" var="conta" itemLabel="#{conta.titulo}"/>
						</h:selectOneMenu>
					</div>
				</div>

				<div class="form-group" style="margin-left: 140px;">
					<div class="col-sm-offset-2 col-sm-10">
						
						<h:commandButton 
							id="btnSalvar"
							action="#{novaReceitaBean.cadastrar}" 
							value="Salvar"
							type="submit" 
							styleClass="btn btn-primary"
							actionListener="#{novaReceitaBean.commandClicked}" />

						<h:commandButton 
							styleClass="btn btn-default" 
							id="bntSalvarContinuar"
							actionListener="#{novaReceitaBean.commandClicked}"
							action="#{novaReceitaBean.cadastrar}"
							value="Salvar e Continuar" type="submit" />
					</div>
				</div>
			</h:form>
		</ui:define>

		<ui:param name="titulo" value="Receita" />
		<ui:param name="tituloPagina" value="Nova Receita" />
	</ui:composition>


</h:body>
</html>